def main():
    D_INPUT = True

    if D_INPUT:
        expr = raw_input()
    else:
        expr = "234 345 456 + + 5 /"
        #expr = "1 2 + +"

    query = expr.split(" ");
    #print query

    stack = []

    try:
        for q in query :
            if q == "+" or q == "-" or q == "*" or q == "/" :
                if len(stack) >= 2 :
                    op2 = stack.pop()
                    op1 = stack.pop()
                    res = eval(str(op1) + q + str(op2))
                    stack.append(res)
                    #print stack
                else:
                    raise Exception("Incorrect expression")
            elif q == "":
                continue
            else :
                stack.append(int(q));
                #print stack
    except ValueError:
        print "ERROR" #print "ERROR - ValueError"
    except ArithmeticError:
        print "ERROR" #print "ERROR - ArithmeticError"
    except Exception as e:
        print "ERROR" #print "ERROR - " + e.message
    else :
        if len(stack) == 1 :
            print stack[0]
        else :
            print "ERROR" #print "ERROR - Len stack is " + str(len(stack))

    #print stack

main()

